package com.restaurant.application.minifacade.data;

import com.google.common.collect.Lists;
import com.nebutown.generation.Convert;
import com.nebutown.generation.PickableBean;

import java.util.List;

public class BookingPageBO implements PickableBean {

    public static final String FN_SHOPID = "shopId";
    public static final String FN_SERVICE = "service";

    public static final List<String> FIELD_NAMES = Lists.newArrayList(
            FN_SHOPID,
            FN_SERVICE);

    private String shopId;
    private String service;

    public BookingPageBO(String shopId, String service) {
        setShopId(shopId);
        setService(service);
    }

    public BookingPageBO() {
    }

    public BookingPageBO duplicate() {
        BookingPageBO result = new BookingPageBO();
        result.shopId = this.shopId;
        result.service = this.service;
        return result;
    }

    @Override
    public String toString() {
        return Convert.toJson(this);
    }

    public String getShopId() {
        return shopId;
    }

    public void setShopId(String value) {
        this.shopId = value;
    }

    public BookingPageBO withShopId(String value) {
        setShopId(value);
        return this;
    }

    public BookingPageBO withShopId(String value, String defaultValue) {
        setShopId(value == null ? defaultValue : value);
        return this;
    }

    public String getService() {
        return service;
    }

    public void setService(String value) {
        this.service = value;
    }

    public BookingPageBO withService(String value) {
        setService(value);
        return this;
    }

    public BookingPageBO withService(String value, String defaultValue) {
        setService(value == null ? defaultValue : value);
        return this;
    }

    public Object getValueOf(String name) {
        switch (name) {
            case "shopId":
                return getShopId();
            case "service":
                return getService();
        }
        return null;
    }

    public boolean hasField(String name) {
        return FIELD_NAMES.contains(name);
    }

    @Override
    public int hashCode() {
        return signature().hashCode();
    }

    @Override
    public boolean equals(Object o) {
        if (!(o instanceof BookingPageBO)) return false;
        return signature().equals(((BookingPageBO) o).signature());
    }

    public String signature() {
        throw new RuntimeException("Bean BookingPageBO has no signature defined, no hash code or equals possible.");
    }
}
